Field of the Invention
The present invention relates to an image processing apparatus and an image processing method for determining whether a document read by a reading device is a color document or a monochrome document.
Description of the Related Art
There is known a technique for determining whether a scanned image read by a reading device is a color image or a monochrome image (hereafter, referred to as color/monochrome determination technique).
In the color/monochrome determination technique, first, (1) determination is made on whether each of pixels in the scanned image is a color pixel or a monochrome pixel based on the saturation of the pixel. Then, (2) determination is made on whether the scanned image is a color image or a monochrome image based on determination results of the respective pixels in the entire scanned image.
In the determination of whether each pixel is a color pixel or a monochrome pixel, problems sometimes occur. For example, in a case where a sheet of a document is recycled paper containing impurities and the like, data of the scanned impurities may sometimes be determined to be color pixels. Moreover, false color and the like occurring in edge portions of monochrome contents due to color shift of the reading device may sometimes be determined to be color pixels. This determination method thus has a problem that, as a result of such erroneous determination, the document is erroneously determined to be a color document despite the fact that contents in the document are monochrome contents.
The color shift described above occurs because sensors of a scanner for R, G, and B catch reflection light from different positions on the document, respectively. Due to this, even in a case where a document including only black objects is scanned, pixels in which R, G, and B are not equal to one another are generated in edge portions of the black objects, and the document is determined to be a color document in some cases.
Moreover, in addition to the color shift, there is a case where accurate monochrome determination cannot be performed for pixels in a portion with a low saturation. For example, in a case where an image is formed of halftone dots as in printed documents, pixels in a gray portion are configured to appear gray in a macro view by mixing three colors of C, M, and Y. Due to this configuration, in a case where the color/monochrome determination is performed on a gray image as described above at a micro level, many pixels are determined to be color pixels.
In order to solve this problem, conceivable is a method of determining whether a target pixel is a color pixel or a monochrome pixel by using not only the saturation of the target pixel but also the saturations of pixels in the vicinity of the target pixels. For example, a following method is conceivable. The average of the saturation of the target pixel and saturations of the pixels in the vicinity of the target pixels is obtained. In a case where the average is greater than a threshold value, the target pixel is determined to be a color pixel. Meanwhile, in a case where the average is smaller than the threshold value, the target pixel is determined to be a monochrome pixel (see Japanese Patent Laid-Open No. 2004-320447).
However, in a case where the aforementioned method is used, the saturation becomes too low due to the averaging and this causes another type of erroneous determination. For example, small color contents such as a string of letters of a small point size are formed of groups of narrow lines and dots. In a case where the averaging processing is performed with a pixel in such small color contents set as the target pixel, the saturation of the color contents of the target pixel decreases due to an effect of pixels in an achromatic color background portion adjacent to the small color contents. This method thus has a problem that an image which should be determined to be a color image is erroneously determined to be a monochrome image as a result of this decrease.